package com.nanbei.heap;


import org.junit.Test;

import java.util.Arrays;
import java.util.PriorityQueue;

/**
 * @ClassDescription:
 * @JdkVersion: 17
 * @Author: BaoShan.li
 * @Created: 2023/12/4 15:39
 */
public class HeapTest {

    @Test
    public void test1(){
        MaxHeap maxHeap = new MaxHeap(7);
        maxHeap.offer(1);
        maxHeap.offer(2);
        maxHeap.offer(3);
        maxHeap.offer(4);
        maxHeap.offer(5);
        maxHeap.offer(6);
        maxHeap.offer(7);
        System.out.println(Arrays.toString(maxHeap.array));

        System.out.println(maxHeap.poll(2));
        System.out.println(Arrays.toString(maxHeap.array));
    }

    @Test
    public void test2(){
        PriorityQueue<Integer> integers = new PriorityQueue<>((a,b)-> b-a);
        integers.offer(1);
        integers.offer(2);
        integers.offer(3);
        integers.offer(4);
        integers.offer(5);
        integers.offer(6);
        integers.offer(7);
        Object[] objects = integers.toArray();


        System.out.println(integers.toString());
    }
}
